<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="../resources/css/main.css" />

<script type="text/javascript" src="../resources/js/jquery-1.4.2.min.js"></script>

<title>.each()</title>

<style type="text/css">



</style>

<script type="text/javascript">
$( function(){
	$('p', "#example-1").each(function(index) {
		$(this).text( "My number is = " + index );
	});		
});

$( function(){
	$('p', "#example-2").each(function(index) {	
		if( index % 2 == 0 )
			$(this).text( " I'm even paragraph " );			
		else
			$(this).text( " I'm odd paragraph " );
	});		
});
</script>
	

</head>

<body>
<h4>.each()</h4>
<hr />
<br />
<div style="background-color: #ADD8E6; padding: 10px;">
	<p> This is summary of the .each() function, to more information see: <a href="http://api.jquery.com/each/" style="text-decoration: none;">.each() Documentation</a>
</div>
<br>

<div style="background-color: #EEEEE0; padding: 10px;">
<pre>
$( function(){
	$('p', "#example-1").each(function(index) {
		$(this).text( "My number is = " + index );
	});		
});
</pre>
</div>
<br>

<div id="example-1">
	<p></p>
	<p></p>
	<p></p>
</div>



<div style="background-color: #EEEEE0; padding: 10px;">
<pre>
$( function(){
	$('p', "#example-2").each(function(index) {	
		if( index % 2 == 0 )
			$(this).text( " I'm even paragraph " );			
		else
			$(this).text( " I'm odd paragraph " );
	});		
});
</pre>
</div>
<br>
<div id="example-2">
	<p></p>
	<p></p>
	<p></p>
	<p></p>
</div>

</body>
</html>